<div class="popup_body">
    <div class="search">
        <div class="float_right">
            <button class="btn btn_yellow" id="query_${pid}">搜索</button>
        </div>
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td align="right" width="95">套餐名称：</td>
                <td><input type="text" class="text" id="setting_name_${pid}"/></td>
            </tr>
        </table>
    </div>
    <div style="width:800px; height:360px; padding-top: 6px;">
        <table id="page_table_${pid}">
        </table>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_yellow" id="delete_${pid}">清空</button>
    <button class="btn btn_red" id="ok_${pid}">确定</button>
    <button class="btn btn_border" id="close_${pid}">关闭</button>
</div>
<script>
    (function() {
            var win = $('#${pid}'), windowData = win.data('windowData');
            var datagrid = $('#page_table_${pid}');
            datagrid.datagrid({
                fit: true,
                width: '100%',
                height: '100%',
                striped: true,
                pagination: true,
                url: "${contextPath}/security/hdw/exchange_price_setting/page.htm?agentId=${agentId}",
                fitColumns: true,
                pageSize: 10,
                pageList: [10, 50, 100],
                idField: 'id',
                singleSelect: true,
                selectOnCheck: true,
                checkOnSelect: true,
                autoRowHeight: false,
                rowStyler: gridRowStyler,
                columns: [
                    [
                        {
                            title: 'checkbox', checkbox: true
                        },
                        {
                            title: '套餐名称',
                            align: 'center',
                            field: 'settingName',
                            width: 200
                        },
                        {
                            title: '日常套餐',
                            align: 'center',
                            field: 'basePriceName',
                            width: 60
                        },
                        {
                            title: '活动套餐',
                            align: 'center',
                            field: 'activityPriceName',
                            width: 60
                        },
                        {
                            title: '活动开始时间',
                            align: 'center',
                            field: 'activityBeginTime',
                            width: 60
                        },
                        {
                            title: '活动结束时间',
                            align: 'center',
                            field: 'activityEndTime',
                            width: 60
                        },
                        {
                            title: '操作',
                            align: 'center',
                            field: 'action',
                            width: 150,
                            formatter: function(val, row) {
                                var html = '<a href="javascript:view_${pid}(ID)">查看</a>';
                                return html.replace(/ID/g, row.id);
                            }
                        }
                    ]
                ],
                onLoadSuccess:function() {
                    datagrid.datagrid('clearChecked');
                    datagrid.datagrid('clearSelections');
                }
            });

            $('#ok_${pid}').click(function() {
                var exchargerPriceSetting = datagrid.datagrid('getSelected');
                if(exchargerPriceSetting) {
                    exchargerPriceSetting = {
                        id: exchargerPriceSetting.id,
                        settingName: exchargerPriceSetting.settingName
                    };
                    windowData.ok({
                        exchargerPriceSetting:exchargerPriceSetting
                    });
                    win.window('close');
                } else {
                    $.messager.alert('提示信息', '请选择套餐');
                }

            });

            $('#close_${pid}').click(function() {
                $('#${pid}').window('close');
            });

            $('#query_${pid}').click(function() {
                query();
            });

            function query() {
                datagrid.datagrid('options').queryParams = {
                    settingName: $('#setting_name_${pid}').val()
                };
                datagrid.datagrid('load');
            }

            $('#delete_${pid}').click(function() {
                var exchargerPriceSetting = datagrid.datagrid('getSelected');
                exchargerPriceSetting = {
                    id: "",
                    settingName: ""
                };
                windowData.ok({
                    exchargerPriceSetting:exchargerPriceSetting
                });
                win.window('close');
            });
        })();

        function view_${pid}(id) {
            App.dialog.show({
                css: 'width:786px;height:515px;',
                title: '查看',
                href: "${contextPath}/security/hdw/exchange_price_setting/view.htm?id=" + id,
                event: {
                    onClose: function() {
                    }
                }
            });
    }

</script>


